<?php

function hgn_dish_basic_form_structure(){
  return array(
    "name"  => array(
      "#type" => "textfield",
      "#title"=> t("Name"),
      "#required" => TRUE,
      "#weight"   => 1,
    ),
    "price"  => array(
      "#type" => "textfield",
      "#title"=> t("Price"),
      "#required" => TRUE,
      "#weight"   => 2,
      "#size" => 10,
      "#field_prefix" => "$",
      "#element_validate"  => array("hgn_price_format_validate"),
    ),
    "description"  => array(
      "#type" => "textarea",
      "#title"=> t("Description"),
      "#weight"   => 3,
    ),
  );
}

/**
 * Show a dish in a page, and all its related info
 */
function hgn_dish_show_form($form,&$form_state,$dish_id){
  // basic info: name, pic_url, description, price
  
  // additional info: Tag
}


/**
 * Show a dish in a page, and all its related info
 */
function hgn_dish_edit_form($form,&$form_state,$dish_id){
  // basic info: name, pic_url, description, price
  
  // additional info: Tag
}


/**
 * Add a Dish
 */
function hgn_dish_add_form($form,&$form_state,$res_id){
  $form = hgn_dish_basic_form_structure();
  $form['submit'] = array(
    "#type" => "submit",
    "#value"=> t("Submit"),
    "#weight"=> 21,
  );
  return $form;
}

function hgn_price_format_validate($form,&$form_state){
  if(!preg_match("/^\\d+\\.\\d+$/", $form_state['values']['price'])){
    form_set_error('price',"Price format error. Please input strictly like: 123.45");
  }
}
